﻿using UnityEngine;
using System.Collections;

public class AssetUpdateShow : MonoBehaviour
{
    private AssetUpdateManager updateManager;
    public UIProgressBar slider;
    public UITweener tweener;
    public void Show()
    {
        gameObject.SetActive(true);
        updateManager = AssetUpdateManager.Instance;
        tweener.ResetToBeginning();
    }

    public void Update()
    {
        if(updateManager.State == AssetUpdateManager.AssetUpdateState.BIG_DOWNLOAD)
        {
            slider.value = (float)((double)updateManager.loadedCount / updateManager.totalDownloadCount);
        }
        else if(updateManager.State == AssetUpdateManager.AssetUpdateState.WAIT_FOR_MOVE)
        {
            slider.value = 1;
            if (!tweener.enabled)
            {
                tweener.PlayForward();
            }
        }
    }
    public void Hide()
    {
        gameObject.SetActive(false);
    }
}
